﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace Controllers
{
    class TrainNeedController : BaseController
    {
        //分页查询,待db添加的deptId字段
        public ActionResult Find(int start, int limit, string idStr)
        {
            int empId;
            IList<int> deptIdList = getAuthedDeptIds("Vehicle", idStr, out empId);
            EmpBasicInfo ebi = Session["ebi"] as EmpBasicInfo;

            IQueryable<TrainNeedDTO> list = from r in ctx.TrainNeeds
                                          orderby r.FormNo descending
                                            select new TrainNeedDTO
                                          {
                                              FormNo = r.FormNo,
                                              DeptName = r.DeptName,
                                              EmpId = r.EmpId,
                                              EmpName = r.Employee.Name,
                                              CreatDate = r.CreatDate,
                                              StatusId = r.StatusId
                                          };
            CJson CJson = new CJson();
            string json = CJson.ToJsonString("totalCount:" + list.Count() + ",data", list.Skip(start).Take(limit).ToList());
            return Content(json);
        }
    }
}